/**
* @file ardoran.h
* @author Alberto Basso, Luca Tumelero
* @brief Set of methods to perform ribbon cable connection checks on Ardoran PCB.
*/
#ifndef ARDORAN_H
#define ARDORAN_H

#include <pcl/common/angles.h>
#include <pcl/common/geometry.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/registration/icp.h>

using namespace std;
using namespace pcl;

/**
 * @brief Check if the base of the ribbon cable on the Ardoran PCB is correctly connected.
 *
 * @param[in] source Pointer to the sample cloud.
 * @param[in] target Pointer to the reference cloud.
 * @param[in] min The minimum point of the bounding box.
 * @param[in] max The maximum point of the bounding box.
 * @param[in] minPercentage The minimum percentage of points inside the reference bounding box to be found inside the sample bounding box.
 * @param[in] maxScore The maximum score.
 * @param[in] verbose True for detailed output on console.
 * @return bool True if the check has been passed (the base of the ribbon cable is correctly connected).
 */
bool checkBase(PointCloud<PointXYZRGB>::Ptr source, PointCloud<PointXYZRGB>::Ptr target, Eigen::Vector4f min, Eigen::Vector4f max, int minPercentage, float maxScore, bool verbose);
/**
 * @brief
 *
 * @param[in] cloud Pointer to the input cloud.
 * @param[in] indices Indices of the input cloud to be processed.
 * @return Eigen::Vector3i The vector containing the average RGB value.
 */
Eigen::Vector3i getAverageColor(PointCloud<PointXYZRGB>::Ptr cloud, vector<int>* indices);
/**
 * @brief Check if the side of the ribbon cable on the Ardoran PCB is correctly connected.
 *
 * @param[in] source Pointer to the sample cloud.
 * @param[in] target Pointer to the reference cloud.
 * @param[in] min The minimum point of the bounding box.
 * @param[in] max The maximum point of the bounding box.
 * @param[in] minPercentage The minimum percentage of points inside the reference bounding box to be found inside the sample bounding box.
 * @param[in] maxColorDiff The maximum color difference.
 * @param[in] verbose True for detailed output on console .
 * @return bool True if the check has been passed (the side of the ribbon cable is correctly connected).
 */
bool checkSide(PointCloud<PointXYZRGB>::Ptr source, PointCloud<PointXYZRGB>::Ptr target, Eigen::Vector4f min, Eigen::Vector4f max, int minPercentage, int maxColorDiff, bool verbose);
/**
 * @brief Return the transformation matrix between source cloud and target cloud.
 *
 * @param[in] source Pointer to the source cloud.
 * @param[in] target Pointer to the target cloud.
 * @return Eigen::Matrix4f Matrix of the transformation to register source to target.
 */
Eigen::Matrix4f getTransformation(PointCloud<PointXYZRGB>::Ptr source, PointCloud<PointXYZRGB>::Ptr target);

#endif // ARDORAN_H

